package com.company.project.sys.service.impl;

import com.company.project.common.utils.ExcelUtils;
import com.company.project.sys.service.BookService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.company.project.sys.mapper.BookMapper;
import com.company.project.sys.entity.BookEntity;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


@Service("bookService")
public class BookServiceImpl extends ServiceImpl<BookMapper, BookEntity> implements BookService {
    @Resource
    BookMapper bookMapper;

    @Override
    public List<BookEntity> selectByUser(String id){
        return bookMapper.selectByUser(id);
    }

    @Override
    public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String[] excelHeader = { "核销时间", "核销门店", "核销类型", "核销内容", "用户", "核销金额", "核销人" };
        String[] columnNames = { "writeDate", "orgName", "type", "couponsName", "userInfo", "price", "writerName" };
        int[] ds_format = { 1, 1, 1, 1, 1, 1, 1 };
        String[] sumColumns = { "", "", "", "", "", "", "" };
        ExcelUtils.export("核销报表.xlsx", null, excelHeader, columnNames, sumColumns, ds_format, null,
                null, request, response);
    }


}